<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% access_token ||= nil %>
<tr class="access_token <%= 'blank' unless access_token %>" style="<%= hidden unless access_token %>">
  <td class="app_name"><%= access_token.try(:app_name) || t(:default_app_name, "No App") %></td>
  <td class="purpose"><%= access_token.try(:purpose) || nbsp %></td>
  <td class="dates">
    <table class="subtable" role="presentation">
      <tr>
        <td><%= before_label(:token_expires, "Expires") %></td>
        <td class="expires nobr"><%= datetime_string(access_token.try(:expires_at)) || t('profile.token_never_expires', 'never') %></td>
      </tr><tr>
        <td class="nobr"><%= before_label(:token_last_used, "Last Used") %></td>
        <td class="used nobr"><%= datetime_string(access_token.try(:last_used_at)) || '--' %></td>
      </tr>
    </table>
  </td>
  <td>
    <a href="#" rel="<%= profile_token_url(access_token.try(:id) || "{{ id }}") %>" class="show_token_link">{{#t}}details{{/t}}</a>
  </td>
  <td class="links">
    <% unless @real_current_user %>
      <a href="#" class="delete_key_link" rel="<%= profile_token_url(access_token.try(:id) || "{{ id }}") %>" title="{{#t}}Delete this Token{{/t}}">{{> icons/trash}}</a>
    <% end %>
  </td>
</tr>
